package com.lyn.hy;

import com.feizhou.swagger.annotation.ApiOperation;
import com.feizhou.swagger.annotation.Param;
import com.feizhou.swagger.annotation.Params;
import com.lyn.common.base.BaseController;
import com.lyn.common.base.Result;
import com.lyn.mango.MangoService;

public class HyydflbController extends BaseController {

    HyydflbService srv = HyydflbService.me;

    @ApiOperation(url = "/insert", httpMethod = "post", description = "新增一行记录")
    @Param(name = "data", description = "新增一行记录", required = true, dataType = "string")
    public void insert() {
        srv.insert(getPara("data"));
        renderJson();
    }

    @ApiOperation(url = "/updateById", httpMethod = "put", description = "根据主键更新单条记录")
    @Param(name = "data", description = "根据主键更新单条记录", required = true, dataType = "string")
    public void updateById() {
        srv.updateById(getPara("data"));
        renderJson();
    }

    @ApiOperation(url = "/updatesById", httpMethod = "put", description = "根据主键更新多条记录")
    @Param(name = "data", description = "根据主键更新多条记录", required = true, dataType = "string")
    public void updatesById() {
        srv.updatesById(getPara("data"));
        renderJson();
    }



    @ApiOperation(url = "/customUpdate", httpMethod = "put", description = "自定义条件更新若干行记录")
    @Param(name = "data", description = "自定义条件更新若干行记录", required = true, dataType = "string")
    public void customUpdate() {
        srv.customUpdate(getPara("data"));
        renderJson();
    }

    @ApiOperation(url = "/getById", httpMethod = "get", description = "获取单条记录的信息")
    @Params({@Param(name = "guid", description = "主键", required = true, dataType = "string"),
            @Param(name = "nian", description = "年", required = true, dataType = "int")})
    public void getById() {
        String id = getPara("guid");
        int nian = getParaToInt("nian");
        Result result = srv.getById(id, nian);
        renderJson(result);
    }

    @ApiOperation(url = "/customSelect", httpMethod = "get", description = "自定义条件查询若干条记录")
    @Params({@Param(name = "nian", description = "年", required = true, dataType = "int"),
            @Param(name = "yue", description = "月", required = true, dataType = "int"),
            @Param(name = "dwdm", description = "单位代码", required = true, dataType = "string")})
    public void customSelect() {
        int nian = getParaToInt("nian");
        int yue = getParaToInt("yue");
        String dwdm = getPara("dwdm");
        Result result = srv.customSelect(nian, yue, dwdm);
        renderJson(result);
    }

    @ApiOperation(url = "/customSelectIn", httpMethod = "get", description = "in语句查询")
    @Params({@Param(name = "nian", description = "年", required = true, dataType = "int"),
            @Param(name = "yue", description = "月", required = true, dataType = "int"),
            @Param(name = "dwdm", description = "单位代码", required = true, dataType = "string"),
            @Param(name = "tjm", description = "统计码", required = true, dataType = "string")})
    public void customSelectIn() {
        int nian = getParaToInt("nian");
        int yue = getParaToInt("yue");
        String dwdm = getPara("dwdm");
        String tjm = getPara("tjm");
        Result result = srv.customSelectIn(nian, yue, dwdm, tjm);
        renderJson(result);
    }

    @ApiOperation(url = "/customSelectLike", httpMethod = "get", description = "like语句查询")
    @Params({@Param(name = "nian", description = "年", required = true, dataType = "int"),
            @Param(name = "yue", description = "月", required = true, dataType = "int"),
            @Param(name = "dwdm", description = "单位代码", required = true, dataType = "string"),
            @Param(name = "tjm", description = "统计码", required = true, dataType = "string")})
    public void customSelectLike() {
        int nian = getParaToInt("nian");
        int yue = getParaToInt("yue");
        String dwdm = getPara("dwdm");
        String tjm = getPara("tjm");
        Result result = srv.customSelectLike(nian, yue, dwdm, tjm);
        renderJson(result);
    }

    @ApiOperation(url = "/customSelectJoin", httpMethod = "get", description = "join语句查询")
    @Params({@Param(name = "nian", description = "年", required = true, dataType = "int"),
            @Param(name = "yue", description = "月", required = true, dataType = "int"),
            @Param(name = "dwdm", description = "单位代码", required = true, dataType = "string")})
    public void customSelectJoin() {
        int nian = getParaToInt("nian");
        int yue = getParaToInt("yue");
        String dwdm = getPara("dwdm");
        Result result = srv.customSelectJoin(nian, yue, dwdm);
        renderJson(result);
    }
}
